<template>
  <div id="qrcode" class="inline-b"></div>
</template>

<script>
export default {
  props: {
    url: {
      type: String,
      default: null
    }
  },
  watch: {
    url() {
      this.createQrCode();
    }
  },
  methods: {
    createQrCode() {
      this.reset();
      new window.QRCode("qrcode", {
        text: this.url,
        width: 200,
        height: 200
      });
      document.getElementById("qrcode").title = "";
    },
    reset() {
      document.getElementById("qrcode").innerHTML = "";
    }
  },
  mounted() {
    this.createQrCode();
  }
};
</script>
